package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicFkReturnItemDAO;
import com.cssy.yd.logic.entity.LogicFkReturnItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-23
 */
public class LogicFkReturnItemDAOImpl extends SqlMapClientDaoSupport implements LogicFkReturnItemDAO {

    /**
     * 插入数据
     * @param logicFkReturnItemDO
     * @return 插入数据的主键
     */
    public String insertLogicFkReturnItemDO(LogicFkReturnItemDO logicFkReturnItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicFkReturnItem.insert", logicFkReturnItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicFkReturnItemDO
     * @return 查出的记录数
     */
    public Integer countLogicFkReturnItemDOByExample(LogicFkReturnItemDO logicFkReturnItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicFkReturnItem.countByDOExample", logicFkReturnItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicFkReturnItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicFkReturnItemDO(LogicFkReturnItemDO logicFkReturnItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicFkReturnItem.update", logicFkReturnItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicFkReturnItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicFkReturnItemDO> findListByExample(LogicFkReturnItemDO logicFkReturnItemDO) throws DataAccessException {
        List<LogicFkReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicFkReturnItem.findListByDO", logicFkReturnItemDO);
        return list;
    }

    /**
     * 根据主键获取logicFkReturnItemDO
     * @param id
     * @return logicFkReturnItemDO
     */
    public LogicFkReturnItemDO findLogicFkReturnItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicFkReturnItemDO logicFkReturnItemDO = (LogicFkReturnItemDO) getSqlMapClientTemplate().queryForObject("LogicFkReturnItem.findByPrimaryKey", id);
        return logicFkReturnItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicFkReturnItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicFkReturnItem.deleteByPrimaryKey", id);
        return rows;
    }

    @SuppressWarnings("unchecked")
	@Override
   	public List<LogicFkReturnItemDO> find(SearchConditions scs)
   			throws DataAccessException {
   		List<LogicFkReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicFkReturnItem_ex.find", scs);
   		   return list;
   	}

   	@Override
   	public Integer count(SearchConditions scs) throws DataAccessException {		
   		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicFkReturnItem_ex.count", scs);
   	      return count;
   	}

	@SuppressWarnings("unchecked")
	@Override
	public List<LogicFkReturnItemDO> finditembytkid(String tkid) throws DataAccessException  {
		 List<LogicFkReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicFkReturnItem_ex.findbytkid", tkid);
	        return list;
	}
}